#include "Protocols/PacketHeader.h"
#include "Protocols/Protocal.h"
#include "Protocols/ProtocalPool.h"
#include "Protocols/ProtocalCode.h"
#include "utilities/NetAddress.h"

DECLARE_PROTOCOLHEADER_BEGIN(ArpHeader)
DECLARE_PROTOCOLHEADER__DEFAULTCONSTRUCTOR(ArpHeader)
	struct HeaderFormat{
		u_short _mHwType;
		u_short _mProType;
		u_char _mHwAdrLen;
		u_char _mIPAdrLen;
		u_short _mMesType;
	};

	int getHeaderLength() const{
		return sizeof(HeaderFormat) + 2 * getHwAdrLength() + 2 * getIPAdrLength();
	}
	
	int getHwAdrLength() const{
		return (int) (((HeaderFormat *)mData)->_mHwAdrLen);
	}
	
	int getIPAdrLength() const{
		return (int) (((HeaderFormat *)mData)->_mIPAdrLen);
	}

	int getProtoType() const{
		return (int)(ntohs(((HeaderFormat *)mData)->_mProType));
	}
	QString getProtoInfo() const;
	NetAddress getSrcHwAdr() const;
	NetAddress getSrcIPAdr() const;
	NetAddress getDesHwAdr() const;
	NetAddress getDesIPAdr() const;
	QString getMesType() const;
	QString getHwType() const;

	QString getSummary() const{
		return QString(" ");
	}
	void toShowableItems(ShowableItem* root) const;
	DECLARE_PROTOCOLHEADER_END
	
	DECLARE_PROTOCOL_BEGIN(ArpProtocal,ArpHeader)
	DECLARE_PROTOCOL_END